package com.zhao.dota.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhao.dota.mapper.PlayerProcessMapper;
import com.zhao.dota.model.PlayerProcess;
import com.zhao.dota.service.PlayerProcessService;
import com.zhao.dota.vo.PlayerProcessVo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlayerProcessServiceImpl extends ServiceImpl<PlayerProcessMapper, PlayerProcess> implements PlayerProcessService {

    @Override
    public void saveList(Integer matchId, List<PlayerProcess> processList) {
        LambdaQueryWrapper<PlayerProcess> query = Wrappers.lambdaQuery(PlayerProcess.class).eq(PlayerProcess::getMatchId, matchId);
        remove(query);
        saveBatch(processList);
    }

    @Override
    public List<PlayerProcessVo> findByMatchId(Integer matchId) {
        return baseMapper.findByMatchId(matchId);
    }
}
